package com.ktjy.mapper;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Demo6 {
    public static void main(String[] args) {
       try{
           Class cls = Class.forName("com.ktjy.pojo.Employee");
           Constructor declaredConstructor = cls.getDeclaredConstructor();
           Object obj = declaredConstructor.newInstance();

           Field empNo = cls.getDeclaredField("empNo");
           Field empName = cls.getDeclaredField("empName");
           Field empPost = cls.getDeclaredField("empPost");
           Field empSalary = cls.getDeclaredField("empSalary");

           empNo.setAccessible(true);
           empNo.set(obj,4312);
           empName.setAccessible(true);
           empName.set(obj,"科泰");
           empPost.setAccessible(true);
           empPost.set(obj,"python");
           empSalary.setAccessible(true);
           empSalary.set(obj,8000);

           Method showInfo = cls.getDeclaredMethod("showInfo");
           showInfo.invoke(obj);
       }catch(Exception e){
           e.printStackTrace();
       }
    }
}
